<?php 
namespace My\Controller;

use Utuo\BackgroundController;

class HaggleController extends BackgroundController {

	// 初始化
	public function _initialize() {
		$this->setControllerTitle('砍价管理');
		$this->setActionTitle(array(
				'index' => '砍价列表',
				'recycle' => '回收站',
		));
		$this->setActionNav(array(
				'index',
				'recycle'
		));
		$this->setLinkNav('设置合作4S店', U('HaggleShop/index'));
	}

	public function indexAction() {
		$this->getLists( 0 );
	}

	public function recycleAction() {
		$this->getLists( 1 );
	}

	public function getLists($is_deleted) {
		$condition = array(
			'is_deleted' => $is_deleted,
			'cid' => $this->aid,
		);
		$page = $this->getPage();
		$pagesize = $this->getPageSize();
		$feedbackLists = M('Haggle')->where($condition)->field('*')->limit($pagesize)->page($page)->order('id desc')->select();
		$count = M('Haggle')->where($condition)->count();
		$this->assign('haggleLists', $feedbackLists);
		$this->showPage($count, $pagesize);
		$this->display();
	}

}